#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
long long f[N];
int main()
{
    int n, m, x, y;
    cin >> n >> m;
    cin >> x;
    for (int i = 2; i <= m; i++)
    {
        cin >> y;
        if (x > y)
        {
            f[x]--;
            f[y]++;
        }
        else
        {
            f[x]++;
            f[y]--;
        }
        x = y;
    }
    for (int i = 1; i <= n; i++)
    {
        f[i] += f[i - 1];
    }
    long long a, b, c;
    long long ret = 0;
    for (int i = 1; i < n; i++)
    {
        cin >> a >> b >> c;
        ret += min(a * f[i], c + b * f[i]);
    }
    cout << ret;
    return 0;
}